Physics · Year 3 11 min read

Statistical Mechanics: Temperature Is What Counting Looks Like

Nothing in a single atom is hot. Temperature, pressure and the arrow of time appear when you count the ways trillions of atoms can arrange themselves, and the biggest count wins by a margin so large it looks like a law.
The Default Library · What Each Major Knows · 84

Shake a box of coins and they land about half heads. Shake a box of a hundred coins and you will rarely get exactly fifty, but you will almost never get ninety. Shake a mole of coins and the fraction of heads will be one half to twelve decimal places, every single time, and nobody calls that a coincidence. They call it a law.

The air in your room works the same way. Its 1026 or so molecules each wander at random, yet the pressure on your eardrum is steady and the temperature is a single number. Nothing in one molecule is "warm". Statistical mechanics is the course that shows temperature, pressure, heat flow and the second law all emerging from one move: count the ways.

If you read Entropy: Why You Can't Unstir Your Coffee (13/12) and Thermodynamics (34/14), you have met the results. This piece shows where they come from, and lets you watch the numbers do it.

The course in one box
Who takes it
Physics majors, usually in year 3 (MIT's 8.044 Statistical Physics I), and chemists and materials scientists in their own versions. Programmes in the style of MIT Course 8 and the Cambridge Natural Sciences physics route teach it after a first quantum course.
What it is for
Deriving the laws of heat, and the properties of gases, solids and radiation, from the rules governing the particles inside them.
Comes after
Probability & Statistics (34/05), Thermodynamics (34/14) and Quantum Mechanics (34/83).
Leads to
Condensed Matter Physics (34/87) and Astrophysics & Cosmology (34/88).
What this piece gives you
You will not be able to compute a partition function for a real material. You will see why temperature is a slope, why large numbers make the second law near-certain, and what the Boltzmann factor is doing in everything from chemistry to stars.

Count the ways: macrostates and microstates

Split the job in two. A microstate is the full detail: which coin shows heads, which molecule is on the left. A macrostate is what you can measure: how many heads, how many molecules on the left. Many microstates make the same macrostate, and the number of them, W, is the multiplicity.

For N coins, the number of ways to get exactly r heads is "N choose r". There is one way to get all heads and an astronomical number of ways to get half. If every microstate is equally likely (the founding assumption), the macrostate with the most microstates wins. As N grows the peak does not just rise: it narrows. The relative width of the heads fraction is 1/(2√N).

Interactive · How sharp does the peak get?
Number of coins (or gas molecules) N

Exact sums of "N choose r" (log-gamma function), shaded band 45% to 55%. The curve is the bell shape of width 1/(2√N), drawn at equal height to show its width. For a mole of molecules the same width is 6.4 × 10−13.

With 100 coins the chance of landing between 45 and 55 heads is about 73%, and exactly 50 only 8%. With 1,000 coins the band holds 99.86%. With 10,000 it holds all but about 2 in 10 billion. Now take N = 6 × 1023: the width is 6.4 × 10−13. This is why "average" and "actual" are the same thing for a gas.

Entropy is a count, and the second law is a bet that wins

Boltzmann's definition (formalised by Planck) is the one formula a graduate remembers, and it is carved on Boltzmann's grave in Vienna:

S = k ln Wentropy = Boltzmann's constant × the logarithm of the number of microstates · k = 1.380649 × 10⁻²³ J/K, exact by definition since 2019

The logarithm is there for a reason: two separate systems multiply their counts, and logs turn products into sums, so entropy adds. Notice what the second law has become. It is not a force. A system drifts to the macrostate with the most microstates because there are overwhelmingly more of them, the way a shuffled deck is not found sorted.

Try it with a small model: N molecules in a box with two halves, all starting on the left. At each step one molecule picked at random hops to the other side (the Ehrenfest urn model of 1907). Nothing in the rule prefers equal halves.

Interactive · Release the gas
Number of molecules

Each step picks one molecule uniformly at random (browser random numbers) and moves it across. S/k = ln(N choose left count). The mean time to return to "all on the left" is 2N steps.

With 10 molecules the count wanders and does return to all-left now and then: on average once in 1,024 steps. With 100 molecules, 2100 is about 1.3 × 1030 steps, which at a million steps a second is about 4 × 1016 years, millions of times the age of the universe. The "law" that gas never gathers on one side is not a prohibition. It is a bet at odds that no one will ever see paid out. In the opposite direction, a 100-molecule system really can fluctuate, which is why small machines (molecular motors, nanoscale devices) behave differently from large ones.

Temperature is how fast entropy grows with energy

Temperature has just been a reading on a thermometer. Here it gets a definition. Put energy into a system and its count of microstates grows. The steepness of that growth is the thing that tells you whether it will give up or accept energy:

1/T = dS/dEtemperature is the inverse of the slope of entropy against energy

The classic model is an Einstein solid: N oscillators sharing q quanta of energy. The number of ways to distribute them is Ω = (q + N − 1)! ÷ (q! (N − 1)!). Check: 3 oscillators sharing 3 quanta can do it 10 ways. Now put two such solids in contact and let quanta move. The combined count is ΩA × ΩB, and the split with the largest product is where the system sits. At that point the two slopes are equal, so the two temperatures are equal. Heat flows from hot to cold because that is the direction that raises the total count.

Interactive · Two blocks trade energy
Oscillators in A
Oscillators in B
Total quanta
Quanta currently in A

ln Ω from the log-gamma function. Temperature in units of ε/k: kT/ε = 1/ln((q+N)/(q+1)), the energy needed per unit entropy gain, found from adding one quantum. Move the quanta slider and watch heat want to flow toward the peak.

Setting A to 100 oscillators and B to 200 with 300 quanta, the peak sits at about 99 quanta in A, one third of the total, matching A's one third of the oscillators. The two temperatures read about 1.45 and 1.46 there (in units of ε/k). Off the peak the hotter block has the lower slope and is the one that loses quanta.

The Boltzmann factor: why cold things are boring

Now stop looking at the whole box and look at one small system (an atom, a molecule) touching a big reservoir at temperature T. The reservoir can lend the small system energy, but lending a lot costs the reservoir many microstates, and each extra bit of energy taken multiplies its count by a fixed factor. The result is the most reused formula in physics.

P(E) ∝ e−E / kTthe odds of finding a state fall off exponentially with its energy, measured in units of kT

kT at 300 K (room temperature) is 25.85 meV (0.0259 eV): the natural thermal energy of a molecule. A state one kT above the ground state is about 37% as likely as the ground state; a state 10 kT up is 0.005% as likely. A molecular vibration (nitrogen's is about 0.29 eV) sits more than 11 kT up, so at room temperature only about 1 molecule in 75,000 is vibrating. That is why room-temperature air heat capacity barely feels vibrations.

Interactive · Warm up a ladder
Temperature
Level spacing

Six equally spaced, non-degenerate levels; population ∝ exp(−nΔE/kT), normalised by the partition function Z. k = 8.617 × 10⁻⁵ eV/K.

The same factor drives chemistry: reaction rates grow like e−Ea/kT (the Arrhenius law), so a reaction with a barrier of 50 kJ/mol goes about 1.9 times faster when 25 °C becomes 35 °C, which is where the rule of thumb "rates double for each 10 degrees" comes from. It drives stars too. Cecilia Payne's 1925 thesis used the Boltzmann factor, together with the matching rule for ionisation, to show that stars are mostly hydrogen: the 10.2 eV needed to lift hydrogen's electron to the level that gives the visible Balmer lines means that at a sun-like 5,772 K only about 5 in a billion neutral hydrogen atoms are in that level at any instant, yet it is enough to produce the lines.

A gas is a distribution, not a speed

Apply the Boltzmann factor to kinetic energy ½mv² and you get Maxwell's 1860 distribution of molecular speeds: a hump that starts at zero, peaks, then has an exponential tail. Two results are worth a lifetime. First, equipartition: every independent way a molecule can store energy as a square (each direction of motion, each rotation) holds on average ½kT. So the average translational energy is 3/2 kT = 38.8 meV at 300 K, for every gas, and heavier molecules simply move slower. Second, the tail: the fraction beyond some speed is controlled by e−mv²/2kT, so it is violently sensitive to mass and temperature.

Worked number: nitrogen at 300 K has a root-mean-square speed of 517 m/s and the most likely speed is 422 m/s. Hydrogen molecules at the same temperature average 1,927 m/s.

Interactive · Tune a gas
Temperature

f(v) = 4π (m/2πkT)3/2 v² e−mv²/2kT. Curve drawn at equal height to show its shape; axis 0 to 12,000 m/s with Earth's escape speed 11,186 m/s marked. The tail fraction is an upper-end measure only: real atmospheres lose gas from the thin top layer, so treat it as a trend, not a loss rate.

At 1,000 K (roughly the temperature of the thin outer atmosphere, which swings with the sun), the fraction of hydrogen molecules above Earth's escape speed is about 10−6, helium about 10−12, and nitrogen about 10−90. That gap is why Earth keeps its nitrogen and oxygen and has lost almost all its free hydrogen and helium.

Information has a heat price: demons and bits

In 1867 James Clerk Maxwell imagined a tiny doorkeeper who watches molecules and opens a gate only for fast ones going one way and slow ones going the other. Without doing any work, it would sort a gas into hot and cold and defeat the second law. The paradox was famous for a century. The resolution came from information: the demon must remember what it saw, and memory is finite, so eventually it must erase. Rolf Landauer (1961) showed that erasing one bit must release at least kT ln 2 of heat, and Charles Bennett (1982) used that to close the case.

Eerase ≥ k T ln 2= 2.87 × 10⁻²¹ J (0.018 eV) per bit at 300 K

That is far below what any chip dissipates, but it is real. In 2012 a team in Lyon trapped a single glass bead in a double well to act as a one-bit memory and measured the heat from erasing it, approaching the limit as they erased slowly (Bérut et al., Nature 483, 187). The idea that information is physical is now a working principle, and it ties statistical mechanics to Computer Architecture (34/25) and Theory of Computation (34/29).

What a graduate just sees

Where it shows up next

If you want to go deeper

The takeaway

Count microstates. Entropy is the logarithm of the count; temperature is how steeply it climbs with energy; the Boltzmann factor e−E/kT weights every state; and for 1023 particles the most likely macrostate is the only one you will ever see. Heat flowing downhill is not a decree but an overwhelming majority.

Try this: this week, ask of anything you meet, "how big is this energy compared with kT?" A 1.5 V battery, a chemical bond, a photon of red light are all hundreds of kT. A hot cup or a warm room is a few. The answer tells you whether heat can wreck it.

Sources & Further Reading

Sources. The counting, Einstein solid, Boltzmann factor, equipartition and Maxwell–Boltzmann results are standard (Schroeder; Kittel & Kroemer). k = 1.380649 × 10⁻²³ J/K exact since the 2019 SI redefinition; other constants CODATA 2018. Planck evaluated k in 1900–1901 and S = k ln W is on Boltzmann's grave in Vienna (Zentralfriedhof). The Ehrenfest urn is from 1907, Maxwell's speed distribution from 1860, and Cecilia Payne's thesis from 1925. Landauer 1961 and Bennett 1982 are cited from the literature. Experiment: Bérut et al., "Experimental verification of Landauer's principle linking information and thermodynamics," Nature 483, 187–190 (8 March 2012). Course contents: MIT OCW 8.044. Every number an interactive shows was computed in node and checked: P(45–55%) = 72.9% for N = 100, 99.86% for N = 1,000; relative width 6.4 × 10⁻¹³ for a mole; 2¹⁰⁰ = 1.27 × 10³⁰; Ω(3,3) = 10; kT = 25.85 meV at 300 K; N₂ at 300 K vrms = 517 m/s; tail fractions 10−5.9 (H₂), 10−12.3 (He), 10−90 (N₂) at 1,000 K; Landauer 2.87 × 10⁻²¹ J at 300 K; Arrhenius ratio 1.92 for 50 kJ/mol between 25 and 35 °C.